package com.guaju.yueshangLife.activity.mine;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import com.guaju.yueshangLife.R;
import com.guaju.yueshangLife.activity.BillActivity;
import com.guaju.yueshangLife.base.BaseActivity;
import com.guaju.yueshangLife.bean.MePocketBean;
import com.guaju.yueshangLife.databinding.ActivityMyPocketBinding;
import com.guaju.yueshangLife.net.ApiEntity;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class MyPocketActivity extends BaseActivity {

    ActivityMyPocketBinding binding;

    @Override
    protected void loadViewLayout() {
        binding = DataBindingUtil.setContentView(this, R.layout.activity_my_pocket);
    }

    @Override
    protected void bindViews() {

    }

    @Override
    protected void processLogic(Bundle savedInstanceState) {
        ApiEntity.mePocket();
    }

    @Override
    protected void setListener() {
        binding.rlBillInfo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MyPocketActivity.this, AcountInfoActivity.class);
                startActivity(intent);
            }
        });

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onPocket(MePocketBean bean) {
        if (bean == null || bean.getData() == null) {
            return;
        }
        MePocketBean.DataBean data = bean.getData();
        String amount = data.getAmount();
        if (!TextUtils.isEmpty(amount)) {
            binding.tvLastMoney.setText(amount);
        }
    }
}
